﻿CREATE PROCEDURE state_WorkFlow_Start
	@ID int,
	@StatusFromID int,
	@StatusToID int
--WITH EXECUTE AS 'AFC-HOME\SQLServer'
/******************** Not Tested!!! **********************/
AS
SET NOCOUNT ON

DECLARE @UpdateTable nvarchar,@StateID int
SELECT 
 @UpdateTable = 'UPDATE '+TableName+' WITH(UPDLOCK) SET StatusID = @StateID WHERE ID = @ID'
,@StateID = dbo.fs_StateID_Start(TableName)
FROM t_State WHERE ID = @StatusToID

EXEC sp_executeSQL @UpdateTable,N'@StateID int,@ID int',@StateID,@ID

RETURN @StateID
